package edu.its.dreamteam.web.utility;

import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;

public class DBUtility {
	public String generateId(){
		SecureRandom random = null;
		try {
			random = SecureRandom.getInstance("SHA1PRNG");
		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
		}
		Integer tmp = new Integer(Math.abs(random.nextInt()));
		return tmp.toString().substring(0,6);
	}
	public int generate() throws NoSuchAlgorithmException{
		SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
		int a = random.nextInt();
		return a;
	}
	public static void main(String[] args) throws NoSuchAlgorithmException {
		System.out.println("1  :  "+new DBUtility().generateId());
		System.out.println("2  :  "+new DBUtility().generateId());		
		System.out.println("1  :  "+new DBUtility().generateId());
		System.out.println("2  :  "+new DBUtility().generateId());
		System.out.println("1  :  "+new DBUtility().generateId());
		System.out.println("2  :  "+new DBUtility().generateId());		
		System.out.println("1  :  "+new DBUtility().generateId());
		System.out.println("2  :  "+new DBUtility().generateId());		
	}
}
